﻿

function LoadControl(TargetDiv, LoadType) {
    debugger;
    //$('#' + TargetDiv).width('400');
    //$("#Profiler").trigger('click');

    $('#breakingTitle').html(LoadType);
    if (LoadType == 'DND') {
        $('#' + TargetDiv).width('1200');
    }
    else if(LoadType == 'Profile') {
        $('#' + TargetDiv).width('1000');
    }
    $('#' + TargetDiv).html('<div class="center"><img src="../assets/images/ajax-loader.gif" /></div>');
    var dt = "{Data:'"+ LoadType +"'}";
    $.ajax({
        type: "POST",
        url: "/Services/ControlLoader.asmx/LoadControl",
        data: dt,
        contentType: "application/json; charset=utf-8",
        dataType: "json",
        success: function (msg) {
            $('#' + TargetDiv).html(msg.d);
        }
    });
}

function LoadNewPost() {
    debugger;
    $.ajax({
        type: "POST",
        url: "/Services/ControlLoader.asmx/LoadNewPost",
        data: "{Data:'TESTDATA:LoadNewPost'}",
        contentType: "application/json; charset=utf-8",
        dataType: "json",
        success: function (msg) {
            $('#breakingNews').prepend(msg.d);
            $.fancybox.close();
        }
    });
}

function LoadFriends() {
    debugger;
    LoaderOn()
    $('#breakingTitle').html("Friends");
    $.ajax({
        type: "POST",
        url: "/Services/ControlLoader.asmx/LoadFriends",
        data: "{Data:'TESTDATA:LoadFriends'}",
        contentType: "application/json; charset=utf-8",
        dataType: "json",
        success: function (msg) {
            $('#breakingNews').html(msg.d);
        },
        error: function (msg) {
            $('#breakingNews').html("-> " + msg.error);
            
        }
    });

}

function LoadPosts(Source) {
    debugger;
    LoaderOn();
    $('#breakingTitle').html("Events");
    $.ajax({
        type: "POST",
        url: "/Services/ControlLoader.asmx/LoadPosts",
        data: "{Data:''}",
        contentType: "application/json; charset=utf-8",
        dataType: "json",
        success: function (msg) {
            $('#breakingNews').html(msg.d);
        },
        error: function (msg) {
            $('#breakingNews').html("-> " + msg.error);

        }
    });

    if (Source == 'new') {
        $.fancybox.close();
    }
}

function LoadLocations() {

    LoadControl('breakingNews', 'Locations');
}

function LoadDragAndDrop(Target) {
    $.ajax({
        type: "POST",
        url: "/Services/ControlLoader.asmx/LoadDragAndDrop",
        data: "{}",
        contentType: "application/json; charset=utf-8",
        dataType: "json",
        success: function (msg) {
            $('#' + Target).html(msg.d);
        }
    });
}

function LoadProfile(Target) {
    $.ajax({
        type: "POST",
        url: "/Services/ControlLoader.asmx/LoadDragAndDrop",
        data: "{}",
        contentType: "application/json; charset=utf-8",
        dataType: "json",
        success: function (msg) {
            $('#' + Target).html(msg.d);
        }
    });
}

function LoaderOn() {

    $('#breakingNews').html("<img src='./assets/images/ajax-loader.gif'/> Loading");
}

